import axios from "axios";
import { ref, onMounted } from "vue";

export default function() {
  let dogList = ref(['https://images.dog.ceo/breeds/hound-basset/n02088238_10113.jpg'])

  async function getDog() {
    try {
      let res = await axios.get('https://dog.ceo/api/breeds/image/random') as any
      dogList.value.push(res.data.message)
    } catch (error) {
      console.log(error)
    }
  }

  onMounted(() => {
    getDog()
  })

  return { dogList, getDog }  // 抛出变量，让外部能够调用
}